import 'package:mobile_vpn/generated/json/base/json_convert_content.dart';
import 'package:mobile_vpn/models/login_entity.dart';

LoginEntity $LoginEntityFromJson(Map<String, dynamic> json) {
  final LoginEntity loginEntity = LoginEntity();
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    loginEntity.avatar = avatar;
  }
  final String? birthday = jsonConvert.convert<String>(json['birthday']);
  if (birthday != null) {
    loginEntity.birthday = birthday;
  }
  final String? nickName = jsonConvert.convert<String>(json['nickName']);
  if (nickName != null) {
    loginEntity.nickName = nickName;
  }
  final String? sex = jsonConvert.convert<String>(json['sex']);
  if (sex != null) {
    loginEntity.sex = sex;
  }
  final String? signature = jsonConvert.convert<String>(json['signature']);
  if (signature != null) {
    loginEntity.signature = signature;
  }
  final String? userPhone = jsonConvert.convert<String>(json['userPhone']);
  if (userPhone != null) {
    loginEntity.userPhone = userPhone;
  }
  final String? accessToken = jsonConvert.convert<String>(json['accessToken']);
  if (accessToken != null) {
    loginEntity.accessToken = accessToken;
  }
  return loginEntity;
}

Map<String, dynamic> $LoginEntityToJson(LoginEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['avatar'] = entity.avatar;
  data['birthday'] = entity.birthday;
  data['nickName'] = entity.nickName;
  data['sex'] = entity.sex;
  data['signature'] = entity.signature;
  data['userPhone'] = entity.userPhone;
  data['accessToken'] = entity.accessToken;
  return data;
}

extension LoginEntityExtension on LoginEntity {
  LoginEntity copyWith({
    String? avatar,
    String? birthday,
    String? nickName,
    String? sex,
    String? signature,
    String? userPhone,
    String? accessToken,
  }) {
    return LoginEntity()
      ..avatar = avatar ?? this.avatar
      ..birthday = birthday ?? this.birthday
      ..nickName = nickName ?? this.nickName
      ..sex = sex ?? this.sex
      ..signature = signature ?? this.signature
      ..userPhone = userPhone ?? this.userPhone
      ..accessToken = accessToken ?? this.accessToken;
  }
}